home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / RequestFile / RequestFile.a next >
Encoding:
Text File  |  1999-02-22  |  9.6 KB  |  316 lines

  1. ;
  2. ; $VER: RequestFile.a v36.1 (c) 1998 by Mauro Panigada
  3. ;
  4. ; Started:  1998.07.16
  5. ; Finished: 1998.07.16
  6. ;
  7. ; Requirements: OS2.0 (#36), 020+
  8. ; Purpose: replace the known RequestFile
  9. ; Note: PURE
  10. ;
  11. ; Template: DRAWER,FILE/K,PATTERN/K,TITLE/K,POSITIVE/K,NEGATIVE/K,ACCEPTPATTERN/K,
  12. ;   REJECTPATTERN/K,SAVEMODE/S,MULTISELECT/S,DRAWERSONLY/S,NOICONS/S,PUBSCREEN/K
  13. ;
  14. ; Note: * when in multiselect mode, the last drawers/file will have a space after
  15. ;   him; but the program which analyzes that line, should not have any problem, if
  16. ;   it is well written.
  17. ;
  18.  
  19.                 incdir  "inc:"
  20.                 include "exec/types.i"
  21.                 include "exec/memory.i"
  22.                 include "exec/libraries.i"
  23.                 include "exec/exec_lib.i"
  24.                 include "dos/dos.i"
  25.                 include "dos/dosextens.i"
  26.                 include "dos/dos_lib.i"
  27.                 include "intuition/intuition.i"
  28.                 include "intuition/intuition_lib.i"
  29.                 include "libraries/asl.i"
  30.                 include "libraries/asl_lib.i"
  31.  
  32.  
  33. call            MACRO
  34.                 jsr     (_LVO\1,a6)
  35.                 ENDM
  36.  
  37.         STRUCTURE internal,0
  38.                 LONG    execbase
  39.                 LONG    dosbase
  40.                 LONG    aslbase
  41.  
  42.                 LABEL   array
  43.                 LONG    drawer
  44.                 LONG    file
  45.                 LONG    pattern
  46.                 LONG    title
  47.                 LONG    positive
  48.                 LONG    negative
  49.                 LONG    acceptpattern
  50.                 LONG    rejectpattern
  51.                 LONG    savemode
  52.                 LONG    multiselect
  53.                 LONG    drawersonly
  54.                 LONG    noicons
  55.                 LONG    pubscreen
  56.  
  57.                 LONG    oldstack
  58.  
  59.                 WORD    returncode
  60.  
  61.                 STRUCT  buffer,48
  62.  
  63.                 STRUCT  rejectbuffer,32
  64.                 STRUCT  acceptbuffer,32
  65.  
  66.                 LABEL   s_size
  67.  
  68.  
  69.                 opt     p=68020         ; try with new style
  70.  
  71. LIBVERSION      EQU     36
  72.  
  73.  
  74.         SECTION reqfile,CODE
  75.  
  76.                 bra.s   start
  77.  
  78.                 dc.b    "$VER: RequestFile 36.1 [020+] (1998.07.16) "
  79.                 dc.b    "by Mauro Panigada",13,10,0
  80.                 even
  81.  
  82. start           move.l  sp,a0
  83.                 move.w  #(s_size/2)-1,d0
  84. lup             clr.w   -(sp)
  85.                 dbf     d0,lup
  86.                 move.l  sp,a5
  87.                 move.l  a0,(oldstack,a5)
  88.  
  89.                 move.b  #30,(returncode+1,a5)
  90.                 move.l  (4).w,a6
  91.                 move.l  a6,(a5)
  92.                 lea     (dosname,pc),a1
  93.                 moveq   #LIBVERSION,d0
  94.                 call    OpenLibrary
  95.                 move.l  d0,(dosbase,a5)
  96.                 beq     exit0
  97.                 lea     (aslname,pc),a1
  98.                 moveq   #LIBVERSION,d0
  99.                 call    OpenLibrary
  100.                 move.l  d0,(aslbase,a5)
  101.                 beq     exit0
  102.  
  103.                 clr.b   (returncode+1,a5)
  104.                 move.l  (dosbase,a5),a6
  105.                 lea     (template,pc),a0
  106.                 move.l  a0,d1
  107.                 move.l  a5,d2
  108.                 add.l   #array,d2
  109.                 moveq   #0,d3
  110.                 call    ReadArgs
  111.                 move.l  d0,d7                   ; d7 = readargs
  112.                 beq     doserror
  113.  
  114. ; qui crea i tags per aprire il requester....
  115.  
  116.                 suba.l  a0,a0
  117.                 moveq   #ASL_FileRequest,d0
  118.                 move.l  (aslbase,a5),a6
  119.                 call    AllocAslRequest
  120.                 move.l  d0,d6                   ; d6 = asl request
  121.                 beq     aslerror
  122.  
  123.                 move.l  (dosbase,a5),a6
  124.                 move.l  sp,a4                   ; a4 = mediostack
  125.                 clr.l   -(sp)
  126.                 move.l  (pubscreen,a5),d0
  127.                 beq.s   nops
  128.                 move.l  d0,-(sp)
  129.                 move.l  #ASLFR_PubScreenName,-(sp)
  130. nops            move.l  (drawer,a5),d0
  131.                 beq.s   nodrawer
  132.                 move.l  d0,-(sp)
  133.                 move.l  #ASLFR_InitialDrawer,-(sp)
  134. nodrawer        move.l  (file,a5),d0
  135.                 beq.s   nofile
  136.                 move.l  d0,-(sp)
  137.                 move.l  #ASLFR_InitialFile,-(sp)
  138. nofile          move.l  (pattern,a5),d0
  139.                 beq.s   nopatt
  140.                 move.l  d0,-(sp)
  141.                 move.l  #ASLFR_InitialPattern,-(sp)
  142.                 move.l  #1,-(sp)
  143.                 move.l  #ASLFR_DoPatterns,-(sp)
  144. nopatt          move.l  (title,a5),d0
  145.                 beq.s   notit
  146.                 move.l  d0,-(sp)
  147.                 move.l  #ASLFR_TitleText,-(sp)
  148. notit           move.l  (positive,a5),d0
  149.                 beq.s   noposi
  150.                 move.l  d0,-(sp)
  151.                 move.l  #ASLFR_PositiveText,-(sp)
  152. noposi          move.l  (negative,a5),d0
  153.                 beq.s   nonega
  154.                 move.l  d0,-(sp)
  155.                 move.l  #ASLFR_NegativeText,-(sp)
  156. nonega          move.l  (acceptpattern,a5),d1
  157.                 beq.s   noap
  158.                 lea     (acceptbuffer,a5),a0
  159.                 move.l  a0,d2
  160.                 moveq   #32,d3
  161.                 call    ParsePatternNoCase
  162.                 lea     (acceptbuffer,a5),a0
  163.                 move.l  a0,-(sp)
  164.                 move.l  #ASLFR_AcceptPattern,-(sp)
  165. noap            move.l  (rejectpattern,a5),d1
  166.                 beq.s   norejp
  167.                 lea     (rejectbuffer,a5),a0
  168.                 move.l  a0,d2
  169.                 moveq   #32,d3
  170.                 call    ParsePatternNoCase
  171.                 lea     (rejectbuffer,a5),a0
  172.                 move.l  a0,-(sp)
  173.                 move.l  #ASLFR_RejectPattern,-(sp)
  174. norejp          move.l  (savemode,a5),d0
  175.                 beq.s   nosamo
  176.                 move.l  d0,-(sp)
  177.                 move.l  #ASLFR_DoSaveMode,-(sp)
  178. nosamo          move.l  (multiselect,a5),d0
  179.                 beq.s   nomusel
  180.                 move.l  d0,-(sp)
  181.                 move.l  #ASLFR_DoMultiSelect,-(sp)
  182. nomusel         move.l  (drawersonly,a5),d0
  183.                 beq.s   nodon
  184.                 move.l  d0,-(sp)
  185.                 move.l  #ASLFR_DrawersOnly,-(sp)
  186. nodon           move.l  (noicons,a5),d0
  187.                 beq.s   nonoi
  188.                 move.l  d0,-(sp)
  189.                 move.l  #ASLFR_RejectIcons,-(sp)
  190. nonoi
  191.  
  192.                 move.b  #20,(returncode+1,a5)
  193.                 move.l  d6,a0
  194.                 move.l  sp,a1
  195.                 move.l  (aslbase,a5),a6
  196.                 call    AslRequest
  197.                 move.l  a4,sp
  198.                 tst.l   d0
  199.                 beq     exit2
  200.  
  201.                 clr.b   (returncode+1,a5)
  202.                 move.l  d6,a0
  203.                 tst.l   (multiselect,a5)
  204.                 bne     yesmulsel
  205.  
  206.                 move.l  (fr_File,a0),d2
  207.                 bsr     CAddPart
  208.  
  209.                 lea     (replacet,pc),a0
  210.                 bsr     CWrite
  211.                 bra     exit2
  212.  
  213. yesmulsel
  214.                 move.l  (fr_NumArgs,a0),d4
  215.                 subq.w  #1,d4                   ; numero argomenti
  216.                 move.l  (fr_ArgList,a0),a4
  217.                 cmp.l   #0,a4
  218.                 beq     unknownerr
  219.  
  220. yms_loop        addq.l  #4,a4
  221.                 move.l  (a4)+,d2
  222.                 bsr     CAddPart
  223.                 lea     (replacet0,pc),a0
  224.                 bsr     CWrite
  225.                 dbf     d4,yms_loop
  226.                 lea     (accapo,pc),a0
  227.                 move.l  a0,d1
  228.                 call    PutStr
  229.  
  230.  
  231. exit2
  232.                 move.l  d6,a0
  233.                 move.l  (aslbase,a5),a6
  234.                 call    FreeAslRequest
  235. exit1
  236.                 move.l  d7,d1
  237.                 move.l  (dosbase,a5),a6
  238.                 call    FreeArgs
  239. exit0
  240.                 move.l  (a5),a6
  241.                 move.l  (dosbase,a5),a1
  242.                 call    CloseLibrary
  243.                 move.l  (aslbase,a5),a1
  244.                 call    CloseLibrary
  245.                 move.l  (oldstack,a5),sp
  246.                 moveq   #0,d0
  247.                 move.w  (returncode,a5),d0
  248.                 rts
  249.  
  250. doserror
  251.                 call    IoErr
  252.                 move.l  d0,d1
  253.                 moveq   #0,d2
  254.                 call    PrintFault
  255. frega0          move.b  #30,(returncode+1,a5)
  256.                 bra.s   exit0
  257.  
  258. aslerror
  259.                 move.l  (dosbase,a5),a6
  260.                 lea     (aslerrstr,pc),a0
  261.                 move.l  a0,d1
  262.                 call    PutStr
  263.                 move.b  #30,(returncode+1,a5)
  264.                 bra.s   exit1
  265.  
  266. unknownerr      move.b  #30,(returncode+1,a5)
  267.                 bra.s   exit2
  268.  
  269.  
  270. ; IN   a0 = fr struct
  271. ;      a5 = DO NOT TOUCH reserved base
  272. ;      d2 = file to append
  273. ;
  274. CAddPart        move.l  d6,a0
  275.                 move.l  (fr_Drawer,a0),a1
  276.                 lea     (buffer,a5),a2
  277.                 move.l  a2,d1
  278.                 moveq   #47,d3
  279. clup            move.b  (a1)+,(a2)+
  280.                 tst.b   -1(a1)
  281.                 dbeq    d3,clup
  282.                 moveq   #48,d3
  283.                 move.l  (dosbase,a5),a6
  284.                 call    AddPart         ; quello che è uscito, è uscito!
  285.                 rts
  286.  
  287. ; IN  a0 = replacetx
  288. ;
  289. CWrite          lea     (buffer,a5),a1
  290.                 move.l  a1,-(sp)
  291.                 move.l  sp,d2
  292.                 move.l  a0,d1
  293.                 move.l  (dosbase,a5),a6
  294.                 call    VPrintf
  295.                 addq.l  #4,sp
  296.                 rts
  297.  
  298.  
  299. ;====================================================================================
  300.  
  301. template        dc.b    "DRAWER,FILE/K,PATTERN/K,TITLE/K,POSITIVE/K,NEGATIVE/K,ACCEPTPATTERN/K,"
  302.                 dc.b    "REJECTPATTERN/K,SAVEMODE/S,MULTISELECT/S,DRAWERSONLY/S,NOICONS/S,PUBSCREEN/K",0
  303.  
  304. dosname         dc.b    "dos.library",0
  305. aslname         dc.b    "asl.library",0
  306.  
  307. noicpatt        dc.b    "#?.info",0
  308.  
  309. aslerrstr       dc.b    "Error while allocating requester!",10,0
  310.  
  311. replacet        dc.b    '"%s"'
  312. accapo          dc.b    10,0
  313. replacet0       dc.b    '"%s" ',0
  314.  
  315.                 END
  316.